/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.aigestudio.wheelpicker.demo;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import com.aigestudio.wheelpicker.WheelPicker;

import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
import ohos.agp.text.Font;
import ohos.agp.utils.Color;
import ohos.app.Context;

import org.junit.Before;
import org.junit.Test;

import java.util.ArrayList;

/**
 * TestCases for WheelPicker
 */
public class WheelPickerTest {
    private WheelPicker wheelPicker;

    private Context context;

    /**
     * setup for testCases
     */
    @Before
    public void setup() {
        context = AbilityDelegatorRegistry.getAbilityDelegator().getAppContext();
        wheelPicker = new WheelPicker(context);
    }

    /**
     * test case for CurtainColor
     */
    @Test
    public void testCurtainColor() {
        wheelPicker.setCurtainColor(Color.GREEN.getValue());
        assertEquals(Color.GREEN.getValue(), wheelPicker.getCurtainColor());
    }

    /**
     * test case for set data
     */
    @Test
    public void testSetData() {
        ArrayList<String> items = new ArrayList<>();
        items.add("Monday");
        items.add("Tuesday");
        items.add("Wednesday");
        items.add("Thursday");
        items.add("Friday");
        items.add("Saturday");
        items.add("Sunday");

        wheelPicker.setData(items);
        assertEquals(items, wheelPicker.getData());
    }

    /**
     * test case for ItemAlign
     */
    @Test
    public void testItemAlign() {
        wheelPicker.setItemAlign(WheelPicker.ALIGN_RIGHT);
        assertEquals(WheelPicker.ALIGN_RIGHT, wheelPicker.getItemAlign());
    }

    /**
     * test case for ItemSpace
     */
    @Test
    public void testItemSpace() {
        wheelPicker.setItemSpace(10);
        assertEquals(10, wheelPicker.getItemSpace());
    }

    /**
     * test case for ItemTextColor
     */
    @Test
    public void testItemTextColor() {
        wheelPicker.setItemTextColor(Color.RED.getValue());
        assertEquals(Color.RED.getValue(), wheelPicker.getItemTextColor());
    }

    /**
     * test case for ItemTextSize
     */
    @Test
    public void testItemTextSize() {
        wheelPicker.setItemTextSize(18);
        assertEquals(18, wheelPicker.getItemTextSize());
    }

    /**
     * test case for MaximumWidthText
     */
    @Test
    public void testMaximumWidthText() {
        wheelPicker.setMaximumWidthText("Wednesday");
        assertEquals("Wednesday", wheelPicker.getMaximumWidthText());
    }

    /**
     * test case for MaximumWidthTextPosition
     */
    @Test
    public void testMaximumWidthTextPosition() {
        wheelPicker.setMaximumWidthTextPosition(5);
        assertEquals(5, wheelPicker.getMaximumWidthTextPosition());
    }

    /**
     * test case for SelectedItemPosition
     */
    @Test
    public void testSelectedItemPosition() {
        wheelPicker.setSelectedItemPosition(3);
        wheelPicker.setSelectedItemPosition(3);
        assertEquals(3, wheelPicker.getCurrentItemPosition());
    }

    /**
     * test case for SelectedItemColor
     */
    @Test
    public void testSelectedItemColor() {
        wheelPicker.setSelectedItemTextColor(Color.RED.getValue());
        assertEquals(Color.RED.getValue(), wheelPicker.getSelectedItemTextColor());
    }

    /**
     * test case for Typeface
     */
    @Test
    public void testTypeface() {
        wheelPicker.setTypeface(Font.MONOSPACE);
        assertEquals(Font.MONOSPACE, wheelPicker.getTypeface());
    }

    /**
     * test case for VisibleItemCount
     */
    @Test
    public void testVisibleItemCount() {
        wheelPicker.setVisibleItemCount(5);
        assertEquals(5, wheelPicker.getVisibleItemCount());
    }

    /**
     * test case for IndicatorSize
     */
    @Test
    public void testIndicatorSize() {
        wheelPicker.setIndicatorSize(15);
        assertEquals(15, wheelPicker.getIndicatorSize());
    }

    /**
     * test case for IndicatorColor
     */
    @Test
    public void testIndicatorColor() {
        wheelPicker.setIndicatorColor(Color.BLUE.getValue());
        assertEquals(Color.BLUE.getValue(), wheelPicker.getIndicatorColor());
    }

    /**
     * test case for Atmospheric
     */
    @Test
    public void testAtmospheric() {
        wheelPicker.setAtmospheric(true);
        assertTrue(wheelPicker.hasAtmospheric());
    }

    /**
     * test case for Curtain
     */
    @Test
    public void testCurtain() {
        wheelPicker.setCurtain(true);
        assertTrue(wheelPicker.hasCurtain());
    }

    /**
     * test case for Curved
     */
    @Test
    public void testCurved() {
        wheelPicker.setCurved(true);
        assertTrue(wheelPicker.isCurved());
    }

    /**
     * test case for Cyclic
     */
    @Test
    public void testCyclic() {
        wheelPicker.setCyclic(true);
        assertTrue(wheelPicker.isCyclic());
    }

    /**
     * test case for Indicator
     */
    @Test
    public void testIndicator() {
        wheelPicker.setIndicator(true);
        assertTrue(wheelPicker.hasIndicator());
    }

    /**
     * test case for SameWidth
     */
    @Test
    public void testSameWidth() {
        wheelPicker.setSameWidth(true);
        assertTrue(wheelPicker.hasSameWidth());
    }
}